<template>
  <el-card class="box-card">
    <div slot="header" class="clearfix">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="商家名称:">
          <el-input
            v-model="formInline.shop_name"
            placeholder="请输入商家名称"
          ></el-input>
        </el-form-item>
        <el-form-item label="订单号:">
          <el-input
            v-model="formInline.order_no"
            placeholder="请输入订单号"
          ></el-input>
        </el-form-item>
        <!-- <el-form-item label="商品名称:">
          <el-input v-model="formInline.region" placeholder="请输入商品名称"></el-input>
        </el-form-item> -->
        <el-form-item label="收货人姓名:">
          <el-input
            v-model="formInline.consignee"
            placeholder="请输入收货人姓名"
          ></el-input>
        </el-form-item>
        <el-form-item label="收货人手机号:">
          <el-input
            v-model="formInline.consignee_phone"
            placeholder="请输入收获人手机号"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <div class="gauge">
            <el-button type="primary" @click="onSubmit">查询</el-button>
            <el-button type="primary" @click="onReset">重置</el-button>
          </div>
        </el-form-item>
      </el-form>
    </div>
    <div class="text item">
      <!-- <span class="gauge">订单收入金额:222223333 元</span> -->
      <el-table
        v-loading="loading"
        :data="tableData"
        border
        style="width: 100%"
        max-height="600"
      >
        <el-table-column
          type="index"
          align="center"
          label="序号"
          :index="indexMethod"
          width="70"
        >
        </el-table-column>
        <el-table-column prop="img" align="center" label="商家信息" width="300">
          <template slot-scope="scope">
            <div class="modality">
              <el-image
                style="width: 70px; height: 70px; width: 20%"
                :src="imgHeader + scope.row.logo"
                class="leftImg"
              ></el-image>
              <div class="modalityUser">
                <el-tooltip
                  class="item"
                  effect="dark"
                  :content="scope.row.shop_name"
                  placement="top-start"
                >
                  <span class="text">公司名称:{{ scope.row.shop_name }}</span>
                </el-tooltip>
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="order_no"
          align="center"
          label="订单号"
          width="140"
        >
        </el-table-column>
        <el-table-column prop="create_time" align="center" label="下单时间">
        </el-table-column>
        <!-- <el-table-column prop="order_no" align="center" label="关联订单">
        </el-table-column> -->
        <el-table-column prop="person_name" align="center" label="收货人姓名">
        </el-table-column>
        <el-table-column
          prop="person_phone"
          align="center"
          label="收货人手机号"
        >
        </el-table-column>
        <el-table-column
          prop="ship_address_ds"
          align="center"
          label="收货人地址"
        >
          <template slot-scope="scope">
            <el-tooltip
              class="item"
              effect="dark"
              :content="scope.row.ship_address_ds"
              placement="top-start"
            >
              <span class="text shouhuo">{{ scope.row.ship_address_ds }}</span>
            </el-tooltip>
          </template>
        </el-table-column>
        <el-table-column prop="pay_status_text" align="center" label="支付状态">
        </el-table-column>
        <el-table-column
          prop="ship_status_text"
          align="center"
          label="发货状态"
        >
        </el-table-column>
        <el-table-column prop="notes" align="center" label="备注">
          <template slot-scope="scope">
            <el-tooltip
              class="item"
              effect="dark"
              :content="scope.row.notes"
              placement="top-start"
            >
              <span class="text shouhuo">{{ scope.row.notes }}</span>
            </el-tooltip>
          </template>
        </el-table-column>
        <el-table-column prop="status_text" align="center" label="状态">
        </el-table-column>
        <el-table-column label="操作" align="center" width="200">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="primary"
              @click="handleEdit(scope.row, false)"
              >查看</el-button
            >
            <el-button
              size="mini"
              type="success"
              @click="handleEdit(scope.row, true)"
              v-if="scope.row.status == 0"
              >去处理</el-button
            >
            <el-button
              size="mini"
              type="warning"
              @click="handleEdit(scope.row, true)"
              v-if="scope.row.pay_status == 1 && scope.row.status == 1"
              >编辑</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- //分页器 -->
    <div class="block">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="page"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="limit"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </div>
    <el-dialog
      :visible.sync="dialogVisible"
      width="65%"
      :before-close="handleClose"
    >
      <span>
        <el-form ref="dataCollection" :model="form" label-width="100px">
          <!-- <span>
              <h4>商家信息</h4>
            </span>
            <el-form-item label="商家名称" class="spanMag">
              {{ form.seller_shop_name }}
            </el-form-item>
            <el-form-item label="负责人姓名" class="spanMag">
              {{ form.manager_name }}
            </el-form-item> -->
          <span>
            <h4>用户信息</h4>
          </span>
          <el-form-item label="用户名" class="spanMag">
            {{ form.user_info ? form.user_info.nickname : "" }}
          </el-form-item>
          <el-form-item label="用户手机号" class="spanMag">
            {{ form.user_info ? form.user_info.mobile : "" }}
          </el-form-item>
          <span>
            <h4>收货人信息</h4>
          </span>
          <el-form-item label="收货人" class="spanMag">
            {{ form.person_name }}
          </el-form-item>
          <el-form-item label="联系方式" class="spanMag">
            {{ form.person_phone }}
          </el-form-item>
          <el-form-item label="收货地址" class="spanMag">
            {{ form.ship_address_ds + form.person_address }}
          </el-form-item>
          <el-form-item label="支付方式" class="spanMag">
            {{
              form.order_info
                ? form.order_info.payment_code == "materialspay"
                  ? "余额支付"
                  : form.order_info.payment_code == "wechatpay"
                  ? "微信支付"
                  : ""
                : ""
            }}
          </el-form-item>
          <el-form-item label="预约送达时间" class="spanMag">
            {{ form.person_time }}
          </el-form-item>
          <!-- <div v-if="this.form.length != 0"> -->
          <span>
            <h4>配送信息</h4>
          </span>
          <el-form-item label="配送方式" class="spanMag">
            {{ form.delivery_method_text }}
          </el-form-item>
          <el-form-item label="运费" class="spanMag">
            {{ form.order_info ? form.order_info.sender_amount : "" }}
          </el-form-item>
          <el-form-item label="上楼方式" class="spanMag">
            {{ form.up_method_text }}
          </el-form-item>
          <el-form-item
            label="首楼踏数"
            class="spanMag"
            v-if="form.up_method > 1 && form.up_method == 3"
          >
            {{ form.up_method_text }}踏
          </el-form-item>
          <el-form-item
            label="后续楼层"
            class="spanMag"
            v-if="form.up_method > 1 && form.up_method == 3"
          >
            {{ form.floors_num }}楼
          </el-form-item>
          <el-form-item
            label="平移搬运距离"
            class="spanMag"
            v-if="form.up_method > 1"
          >
            {{ form.transport }}米
          </el-form-item>
          <el-form-item
            label="途中台阶数"
            class="spanMag"
            v-if="form.up_method > 1"
          >
            {{ form.way_footstep_num }}踏
          </el-form-item>
          <!-- </div> -->
          <div v-if="!addBtnFlag">
            <span>
              <h4>发票信息</h4>
            </span>
            <el-form-item class="spanMag fapiao">
              <el-descriptions title="">
                <el-descriptions-item
                  label="发票ID"
                  v-if="form.fapiao_status == 1"
                  >{{ form.invoice[0].id }}</el-descriptions-item
                >
                <el-descriptions-item
                  label="抬头"
                  v-if="form.fapiao_status == 1"
                  >{{ form.invoice[0].name }}</el-descriptions-item
                >
                <el-descriptions-item
                  label="手机号"
                  v-if="form.fapiao_status == 1"
                  >{{ form.invoice[0].phone }}</el-descriptions-item
                >
                <el-descriptions-item
                  label="邮箱"
                  v-if="form.fapiao_status == 1"
                  >{{ form.invoice[0].email }}</el-descriptions-item
                >
                <el-descriptions-item
                  label="发票类型"
                  v-if="form.fapiao_status == 1"
                  >{{
                    form.invoice[0].type == 1 ? "个人" : "企业"
                  }}</el-descriptions-item
                >
                <el-descriptions-item
                  label="税号"
                  v-if="form.fapiao_status == 1 && form.invoice[0].type == 2"
                  >{{ form.invoice[0].duty }}</el-descriptions-item
                >
                <el-descriptions-item
                  label="企业地址"
                  v-if="form.fapiao_status == 1 && form.invoice[0].type == 2"
                  >{{ form.invoice[0].address }}</el-descriptions-item
                >
                <el-descriptions-item
                  label="企业电话"
                  v-if="form.fapiao_status == 1 && form.invoice[0].type == 2"
                  >{{ form.invoice[0].enterprise_phone }}</el-descriptions-item
                >
                <el-descriptions-item
                  label="开户行名称"
                  v-if="form.fapiao_status == 1 && form.invoice[0].type == 2"
                  >{{ form.invoice[0].row_name }}</el-descriptions-item
                >
                <el-descriptions-item
                  label="开户行账号"
                  v-if="form.fapiao_status == 1 && form.invoice[0].type == 2"
                  >{{ form.invoice[0].account }}</el-descriptions-item
                >
                <el-descriptions-item label="提示">
                  <el-tag size="small">暂无开票</el-tag>
                </el-descriptions-item>
              </el-descriptions>
            </el-form-item>
          </div>
          <span>
            <h4>订单备注</h4>
          </span>
          <el-form-item label="订单备注" class="spanMag">
            {{ form.remark }}
          </el-form-item>
          <div v-if="!addBtnFlag">
            <span>
              <h4>商品信息</h4>
            </span>
            <!-- <el-form-item label="商品信息" class="spanMag">
              <el-table :data="form.goods_lists" border style="width: 100%">
                <el-table-column
                  prop="gooda_name"
                  align="center"
                  label="商品名称"
                  width="180"
                >
                </el-table-column>
                <el-table-column
                  prop="price"
                  align="center"
                  label="商品单价"
                  width="180"
                >
                </el-table-column>
                <el-table-column prop="nums" align="center" label="购买数量">
                </el-table-column>
                <el-table-column align="center" label="商品总价">
                  <template slot-scope="scope">
                    {{ scope.row.nums * scope.row.price }}
                  </template>
                </el-table-column>
                <el-table-column align="center" label="是否截断">
                  <template slot-scope="scope">
                    {{ scope.row.truncation == 3 ? "否" : "是" }}
                  </template>
                </el-table-column>
                <el-table-column align="center" label="截断备注">
                  <template slot-scope="scope">
                    {{
                      scope.row.truncation == 1
                        ? "2米截断"
                        : scope.row.truncation_note
                    }}
                  </template>
                </el-table-column>
              </el-table>
            </el-form-item> -->
            <el-table
              :data="goodsTable"
              border
              style="width: 100%"
              max-height="400"
              class="tableBox"
            >
              <el-table-column
                prop="name"
                align="center"
                label="商品名称"
                width=""
              >
              </el-table-column>
              <el-table-column
                prop="order_no"
                align="center"
                label="商品图片"
                width=""
              >
                <template slot-scope="scope">
                  <el-image
                    style="width: 70px; height: 70px; width: 70px"
                    :src="imgHeader + scope.row.img"
                  ></el-image>
                </template>
              </el-table-column>
              <el-table-column
                prop="color"
                align="center"
                label="商品颜色"
                width=""
              >
              </el-table-column>
              <el-table-column
                prop="order_no"
                align="center"
                label="商品类型"
                width=""
              >
                <template slot-scope="scope"> 辅材 </template>
              </el-table-column>
              <el-table-column
                prop="brand_name"
                align="center"
                label="商品品牌"
                width=""
              >
              </el-table-column>
              <el-table-column
                prop="origin"
                align="center"
                label="商品产地"
                width=""
              >
              </el-table-column>
              <el-table-column
                prop="texture"
                align="center"
                label="商品材质"
                width=""
              >
              </el-table-column>
              <el-table-column
                prop="model"
                align="center"
                label="商品型号"
                width=""
              >
              </el-table-column>
              <el-table-column
                prop="size"
                align="center"
                label="商品尺寸"
                width=""
              >
              </el-table-column>
              <el-table-column
                prop="unit"
                align="center"
                label="商品单位"
                width=""
              >
              </el-table-column>
              <el-table-column
                prop="weight"
                align="center"
                label="商品重量"
                width=""
              >
              </el-table-column>
              <el-table-column
                prop="nums"
                align="center"
                label="商品数量"
                width=""
              >
                <!-- <template slot-scope="scope">
                  <el-input
                    type="number"
                    v-model="scope.row.nums"
                    placeholder="数量"
                  ></el-input>
                </template> -->
              </el-table-column>
              <el-table-column
                prop="sell_price"
                align="center"
                label="商品价格"
                width=""
              >
              </el-table-column>
              <!-- <el-table-column
                prop="order_no"
                align="center"
                label="操作"
                width=""
                fixed="right"
              >
                <template slot-scope="scope">
                  <el-button
                    @click.native.prevent="deleteRow(scope.$index, goodsTable)"
                    type="text"
                    size="small"
                  >
                    移除
                  </el-button>
                </template>
              </el-table-column> -->
            </el-table>
            <div>
              商品总价：{{
                form.order_info ? form.order_info.goods_amount : ""
              }}
            </div>
          </div>
          <el-form-item label="手写拍照/截图" class="spanMag">
            <div
              v-for="(item, index) in form.imglist"
              :key="index"
              style="display: inline-block"
            >
              <el-image
                fit="cover"
                style="width: 100px; height: 100px"
                :src="imgHeader + item"
                :preview-src-list="handlePreviewImg(form.imglist1, index)"
              >
              </el-image>
            </div>
          </el-form-item>
          <el-form-item label="产品采购备注" class="spanMag">
            {{ form.notes }}
          </el-form-item>
          <el-form-item
            label="产品采购语音"
            class="spanMag"
            v-if="form.voice_notes1"
          >
            <audio
              ref="audio"
              controls
              :src="imgHeader + form.voice_notes1.tempFilePath"
            ></audio>
          </el-form-item>

          <!-- <div class="textFor">商品总价: {{ form.goods_amount }} 元</div> -->
          <div v-if="addBtnFlag">
            <span style="margin-top: 20px; display: block">
              <h4>添加商品</h4>
            </span>
            <div>
              <el-button type="text" @click="addFuGoods"
                >添加现有商品</el-button
              >
              <!-- <el-button type="text" @click="goAdd">新增商品</el-button> -->
            </div>
            <div>
              <el-table
                :data="goodsTable"
                border
                style="width: 100%"
                max-height="400"
                class="tableBox"
              >
                <el-table-column
                  prop="name"
                  align="center"
                  label="商品名称"
                  width=""
                >
                </el-table-column>
                <el-table-column
                  prop="order_no"
                  align="center"
                  label="商品图片"
                  width=""
                >
                  <template slot-scope="scope">
                    <el-image
                      style="width: 70px; height: 70px; width: 70px"
                      :src="imgHeader + scope.row.img"
                    ></el-image>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="color"
                  align="center"
                  label="商品颜色"
                  width=""
                >
                </el-table-column>
                <el-table-column
                  prop="order_no"
                  align="center"
                  label="商品类型"
                  width=""
                >
                  <template slot-scope="scope"> 辅材 </template>
                </el-table-column>
                <el-table-column
                  prop="brand_name"
                  align="center"
                  label="商品品牌"
                  width=""
                >
                </el-table-column>
                <el-table-column
                  prop="origin"
                  align="center"
                  label="商品产地"
                  width=""
                >
                </el-table-column>
                <el-table-column
                  prop="texture"
                  align="center"
                  label="商品材质"
                  width=""
                >
                </el-table-column>
                <el-table-column
                  prop="model"
                  align="center"
                  label="商品型号"
                  width=""
                >
                </el-table-column>
                <el-table-column
                  prop="size"
                  align="center"
                  label="商品尺寸"
                  width=""
                >
                </el-table-column>
                <el-table-column
                  prop="unit"
                  align="center"
                  label="商品单位"
                  width=""
                >
                </el-table-column>
                <el-table-column
                  prop="weight"
                  align="center"
                  label="商品重量"
                  width=""
                >
                </el-table-column>
                <el-table-column
                  prop="nums"
                  align="center"
                  label="商品数量"
                  width=""
                >
                  <template slot-scope="scope">
                    <el-input
                      type="number"
                      min="0"
                      v-model="scope.row.nums"
                      placeholder="数量"
                    ></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="sell_price"
                  align="center"
                  label="商品价格"
                  width=""
                >
                </el-table-column>
                <el-table-column
                  prop="order_no"
                  align="center"
                  label="操作"
                  width=""
                  fixed="right"
                >
                  <template slot-scope="scope">
                    <el-button
                      @click.native.prevent="
                        deleteRow(scope.$index, goodsTable)
                      "
                      type="text"
                      size="small"
                    >
                      移除
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </div>
          <el-dialog
            width="40%"
            title="选择现有商品"
            :visible.sync="innerVisible"
            append-to-body
            :before-close="handleCloseInner"
          >
            <el-cascader
              v-model="value"
              :options="options"
              :props="propsoption"
              clearable
              collapse-tags
              @change="chooseGoods"
            ></el-cascader>
            <div class="herDist">
              <el-tag
                class="userIndex"
                v-for="(item, index) in selectDate"
                :key="index"
                >{{
                  item.name +
                  "  :" +
                  item.size +
                  "  - " +
                  item.weight +
                  " ￥" +
                  item.sell_price
                }}</el-tag
              >
            </div>
            <el-button
              @click="savegoods"
              type="primary"
              style="margin: 10px auto"
              >提交</el-button
            >
          </el-dialog>
          <!-- <div>
              <el-form-item label="退货单" class="spanMag">
                <el-table max-height="200" :data="form.returnItem" border style="width: 100%">
                  <el-table-column prop="reship_id" label="退货单号" width="">
                  </el-table-column>
                  <el-table-column prop="aftersales_id" label="售后单号" width="">
                  </el-table-column>
                  <el-table-column prop="status_text" label="退货状态" width="150">
                  </el-table-column>
                  <el-table-column prop="ctime" label="退货时间">
                  </el-table-column>
                </el-table>
              </el-form-item>
            </div> -->
        </el-form>
      </span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="save" type="primary" v-if="addBtnFlag"
          >提交</el-button
        >
        <el-button @click="backtrack">返回</el-button>
      </span>
    </el-dialog>
  </el-card>
</template>
  
<script>
import {
  jiancaiHandeWrite,
  writeJiancai,
  listDate,
  getjiancaiGood,
  submitWrite,
} from "../../../../utils/api";
import {
  getFuHandwriting,
  getFuHandwritingDetail,
  addFuHandwriting,
  getFuGoodsClass,
} from "../../../../utils/main";
export default {
  data() {
    return {
      fucaiID: 0,
      selectDate: [],
      value: "",
      loading: false,
      token: sessionStorage.getItem("token"),
      dialogVisible: false,
      innerVisible: false,
      formInline: {
        shop_name: "",
        order_no: "",
        consignee: "",
        consignee_phone: "",
      },
      imgHeader: this.Global.imgHeader,

      tableData: [],
      goodsTable: [],
      //查看
      form: { user_info: {} },
      //分页器
      total: 0,
      limit: 10,
      page: 1,
      total1: 0,
      limit1: 10,
      page1: 1,
      addBtnFlag: false,
      options: [],
      propsoption: {
        multiple: true,
        // lazy: true,
        // lazyLoad: (node, resolve) => {
        //   const { level } = node;
        //   let nodeList = [];
        //   setTimeout(() => {
        //     // const nodes = Array.from({ length: level + 1 })
        //     //   .map(item => ({
        //     //     value: ++id,
        //     //     label: `选项${id}`,
        //     //     leaf: level >= 2
        //     //   }));
        //     // console.log(resolve);
        //     // console.log(level);
        //     if (level == 1) {
        //       this.getSort(node.value)
        //         .then((res) => {
        //           if (res.data.status) {
        //             this.options.find((e) => {
        //               return e.id == node.value;
        //             }).children = res.data.data;
        //           }
        //           nodeList = this.options.find((e) => {
        //             return e.id == node.value;
        //           }).children;
        //           resolve(nodeList);
        //         })
        //         .catch((err) => {
        //           resolve(nodeList);
        //         });
        //     }

        //     if (level == 2) {
        //       let list = [];
        //       getjiancaiGood(this.token, node.value)
        //         .then((res) => {
        //           if (res.data.status) {
        //             list = res.data.data;
        //             list.forEach((item) => {
        //               item.leaf = level >= 2;
        //               item.nums = 0;
        //             });
        //             this.options.forEach((item) => {
        //               if (item.children) {
        //                 item.children.forEach((item2) => {
        //                   if (item2.id == node.value) {
        //                     item2.children = list;
        //                   }
        //                 });
        //               }
        //             });
        //             nodeList = list;
        //             resolve(nodeList);
        //           }
        //         })
        //         .catch((err) => {
        //           resolve(nodeList);
        //         });

        //       // this.getSort(node.value).then(res=>{
        //       //   if(res.data.status){
        //       //     // this.options.find(e=>{return e.id == node.value}).children = res.data.data
        //       //     // console.log(this.options.find(e=>{return e.children.find(e2=>{return e2.id == node.value})}));
        //       //     this.options.forEach(item=>{
        //       //       if(item.children){
        //       //         item.children.forEach(item2=>{
        //       //           if(item2.id == node.value){
        //       //             item2.children
        //       //           }
        //       //         })
        //       //       }
        //       //     })
        //       //   }
        //       //   // resolve(this.options.find(e=>{return e.id == node.value}).children)
        //       // })
        //     }
        //     if (level == 3) {
        //       resolve(nodeList);
        //     }

        //     // 通过调用resolve将子节点数据返回，通知组件数据加载完成
        //   }, 1000);
        // },
        label: "name",
        value: "id",
      },
    };
  },
  methods: {
    // handImg(e) {
    //   return e.split(",")[0];
    // },
    handleCloseInner() {
      this.innerVisible = false;
      this.selectDate = [];
      this.value = "";
    },
    handlePreviewImg(list, index) {
      let arr = [];
      if (list.length == 1) {
        arr.push(list[0]);
      } else if (list.length == 0) {
        return arr;
      } else {
        for (let i = 0; i < list.length; i++) {
          arr.push(list[i + index]);
          if (i + index >= list.length - 1) {
            index = 0 - (i + 1);
          }
        }
      }
      return arr;
    },
    savegoods() {
      this.goodsTable = this.selectDate;
      this.innerVisible = false;
    },
    chooseGoods(e) {
      let list = JSON.parse(JSON.stringify(e));
      console.log(list, "list");
      let list1 = [];
      // console.log(list);
      list.forEach((item) => {
        // if (item.length >= 2) {
        list1.push(
          this.options.find((item1) => {
            return item1.id == item[0];
          })
        );
        //   console.log(item[2]);
        //   // this.options
        // }
      });
      this.selectDate = list1;
      console.log(this.selectDate, "selectDate");
    },
    // 保存   提交
    save() {
      let list = [];
      let reg = /^[1-9]\d*$/;

      this.goodsTable.forEach((item) => {
        if (!reg.test(item.nums)) {
          this.$message("商品数量请输入不是以0开头的正整数");
          return;
        }
        if (item.nums >= 1) {
          list.push({ goods_id: item.id, nums: item.nums });
        }
      });
      if (list.length == 0) {
        this.$message("请填写商品数量");
        return;
      }
      submitWrite(
        this.token,
        this.form.id,
        JSON.stringify(list),
        55,
        this.form.notes,
        this.form.user_id,
        sessionStorage.getItem("user_id")
      ).then((res) => {
        if (res.data.status) {
          this.dialogVisible = false;
          this.getList();
        }
      });
    },
    deleteRow(index, rows) {
      rows.splice(index, 1);
    },
    // goAdd() {
    //   this.$router.push("/list/merchandise");
    // },
    addFuGoods() {
      this.innerVisible = true;
    },
    getList() {
      getFuHandwriting(
        this.token,
        "",
        this.formInline.shop_name,
        this.formInline.order_no,
        this.formInline.consignee,
        this.formInline.consignee_phone,
        this.page,
        this.limit
      ).then((res) => {
        if (res.data.status) {
          this.tableData = res.data.data.data;
          this.total = res.data.data.count;
          this.tableData.forEach((element) => {
            if (element.status != null) {
              // 0 未处理 1 已处理
              if (element.status == 0) {
                element.status_text = "未处理";
              }
              if (element.status == 1) {
                element.status_text = "已处理";
              }
            }
            // 3,已发货，4已送达，1和2都是未发货
            if (element.ship_status) {
              if (element.ship_status == 1 || element.ship_status == 2) {
                element.ship_status_text = "未发货";
              }
              if (element.ship_status == 3) {
                element.ship_status_text = "已发货";
              }
              if (element.ship_status == 4) {
                element.ship_status_text = "已送达";
              }
            }
            if (element.pay_status) {
              // 1=未付款 2=已付款 3=部分付款 4=部分退款
              if (element.pay_status == 1) {
                element.pay_status_text = "未付款";
              }
              if (element.pay_status == 2) {
                element.pay_status_text = "已付款";
              }
              if (element.pay_status == 3) {
                element.pay_status_text = "部分付款";
              }
              if (element.pay_status == 4) {
                element.pay_status_text = "部分退款";
              }
              console.log();
            }
            // if (element.ctime) {
            //   element.time_text = this.timeChange(element.ctime);
            // }

            // if(element.voice_notes)
          });
        }
      });
    },
    getGoodsSelect() {
      getFuGoodsClass(this.token, 35).then((res) => {
        if (res.data.status) {
          this.options = res.data.data;
          // this.total = res.data.data.count;
        }
      });
    },
    // timeChange(e) {
    //   let time = e;
    //   if (typeof time === "number" && time.toString().length === 10) {
    //     time = time * 1000;
    //   }
    //   let date = new Date(time);
    //   let Y = date.getFullYear();
    //   let M = date.getMonth() + 1;
    //   let D = date.getDate();
    //   let hh = date.getHours();
    //   let mm = date.getMinutes();
    //   let ss = date.getSeconds();
    //   M = M < 10 ? "0" + M : M;
    //   D = D < 10 ? "0" + D : D;
    //   hh = hh < 10 ? "0" + hh : hh;
    //   mm = mm < 10 ? "0" + mm : mm;
    //   ss = ss < 10 ? "0" + ss : ss;
    //   return Y + "-" + M + "-" + D + " " + hh + ":" + mm + ":" + ss;
    // },
    //查询
    onSubmit() {
      this.page = 1;
      this.getList();
    },
    //重置
    onReset() {
      (this.formInline = {
        shop_name: "",
        order_no: "",
        consignee: "",
        consignee_phone: "",
      }),
        this.getList();
    },
    // 序号排序
    indexMethod(index) {
      if (this.total < this.limit) {
        return this.total - index;
      } else {
        return this.total - (this.page - 1) * this.limit - index;
      }
    },
    //详情
    handleEdit(row, flag) {
      this.addBtnFlag = flag;
      // console.log(row);
      getFuHandwritingDetail(this.token, row.id).then((res) => {
        if (res.data.status) {
          this.dialogVisible = true;
          this.form = res.data.data;
          this.goodsTable = this.form.goods_list;
          if (this.form.delivery_method == 1) {
            this.form.delivery_method_text = "商家配送";
          }
          if (this.form.delivery_method == 2) {
            this.form.delivery_method_text = "用户自提";
          }
          //1原地卸货 2 电梯上楼 3 楼梯上楼
          if (this.form.up_method == 1) {
            this.form.up_method_text = "原地卸货";
          }
          if (this.form.up_method == 2) {
            this.form.up_method_text = "电梯上楼";
          }
          if (this.form.up_method == 3) {
            this.form.up_method_text = "楼梯上楼";
          }
          this.form.voice_notes1 = JSON.parse(this.form.voice_notes);
          this.form.imglist = this.form.img.split(",");
          this.form.imglist1 = [];
          this.form.img.split(",").forEach((item) => {
            this.form.imglist1.push(this.imgHeader + item);
          });
        }
      });
    },
    //关闭
    handleClose(done) {
      if (this.$refs.audio) {
        this.$refs.audio.pause();
      }
      done();
    },
    //弹框序号
    // indexM(index) {
    // if (this.token < this.limit) {
    //   return this.total - index;
    // } else {
    //   return (
    //     this.total - (this.currentPage - 1) * this.limit - index
    //   );
    // }
    // },
    //返回
    backtrack() {
      this.dialogVisible = false;
    },
    handleSizeChange(val) {
      this.limit = val;
      // console.log(`每页 ${val} 条`);
      this.getList();
    },
    handleCurrentChange(val) {
      this.page = val;
      // console.log(`当前页: ${val}`);
      this.getList();
    },
    // handleSizeChange1(val) {
    //   console.log(`每页 ${val} 条`);
    // },
    // handleCurrentChange1(val) {
    //   console.log(`当前页: ${val}`);
    // },

    // getSort(id) {
    //   return new Promise((resolve, reject) => {
    //     listDate(this.token, this.pageSize, "", id, this.page).then((res) => {
    //       resolve(res);
    //     });
    //   });
    // },
  },
  mounted() {
    this.getList();
    this.getGoodsSelect();

    // listDate(this.token, this.pageSize, "", 0, this.page).then((res) => {
    //   if (res.data.status) {
    //     let lits = res.data.data;
    //     let list1 = lits.filter((item) => {
    //       return item.name == "辅材";
    //     });
    //     this.fucaiID = list1[0].id;
    //     listDate(this.token, this.pageSize, "", list1[0].id, this.page).then(
    //       (res1) => {
    //         if (res.data.status) {
    //           this.options = res1.data.data;
    //         }
    //       }
    //     );
    //   }
    // });
  },
};
</script>
  
<style scoped>
.text {
  font-size: 14px;
}

/* .item {
    margin-bottom: 18px;
} */

.modality {
  display: flex;
  width: 100%;
}

.modality .leftImg {
  width: 20%;
}

.modalityUser {
  display: flex;
  flex-direction: column;
  margin: 0 15px;
  width: 70%;
  justify-content: center;
}

.modalityUser .item {
  display: block;
  text-align: left;
  width: 90%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}

.clearfix:after {
  clear: both;
}

.box-card {
  width: 100%;
}

.demo-form-inline {
  display: flex;
}

.gauge {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.oneLine {
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}

.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.formUser {
  width: 60%;
}

.el-form-item {
  display: flex;
  /* width: 40%; */
}

.el-form-item .el-form-item__label {
  width: 60%;
}

.shouhuo {
  display: -webkit-box;
  /* 必须结合的属性 ，设置或检索伸缩盒对象的子元素的排列方式 。*/
  -webkit-box-orient: vertical;
  /*要显示的行数*/
  -webkit-line-clamp: 2;
  /* 溢出部分隐藏 */
  overflow: hidden;
}
.herDist {
  height: 300px;
  width: 80%;
  border: 1px solid #1a171711;
  overflow: auto;
  margin-top: 20px;
}
.userIndex {
  margin: 10px 10px;
}
.tableBox {
  margin-bottom: 10px;
  margin-top: 10px;
}
</style>